package location.cn.org.wias.wifiscan.entity;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class SpotData implements Serializable {
    private int id;
    private int spot;
    private int building;
    private Map<String, Integer> rssi;
    private float g_x;
    private float g_y;
    private float g_z;
    private String description;
    private int pose;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getSpot() {
        return spot;
    }

    public void setSpot(int spot) {
        this.spot = spot;
    }

    public int getBuilding() {
        return building;
    }

    public void setBuilding(int building) {
        this.building = building;
    }

    public Map<String, Integer> getRssi() {
        if(rssi == null) {
            rssi = new HashMap<>();
        }
        return rssi;
    }

    public void setRssi(Map<String, Integer> bssid) {
        if(bssid == null) {
            bssid = new HashMap<>();
        }
        this.rssi = bssid;
    }

    public float getG_x() {
        return g_x;
    }

    public void setG_x(float g_x) {
        this.g_x = g_x;
    }

    public float getG_y() {
        return g_y;
    }

    public void setG_y(float g_y) {
        this.g_y = g_y;
    }

    public float getG_z() {
        return g_z;
    }

    public void setG_z(float g_z) {
        this.g_z = g_z;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getPose() {
        return pose;
    }

    public void setPose(int pose) {
        this.pose = pose;
    }

    public String toJson(){

        /**
         *  private int id;
         *     private int spot;
         *     private int building;
         *     private Map<String, Integer> rssi;
         *     private float g_x;
         *     private float g_y;
         *     private float g_z;
         *     private String description;
         *     private int pose;
         */
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("id", getId());
            jsonObject.put("spot", getSpot());
            jsonObject.put("building", getBuilding());
            jsonObject.put("rssi", getRssi());
            jsonObject.put("get_x", getG_x());
            jsonObject.put("get_y", getG_y());
            jsonObject.put("get_z", getG_z());
            jsonObject.put("description", getDescription());
            jsonObject.put("pose", getPose());

            return jsonObject.toString();
        } catch (JSONException e) {
            e.printStackTrace();
            return  "";
        }
    }
}
